/**
 * Created by ly on 2015/4/26.
 */
/**
 * 动态改变dom，需使用injector编译并连接到angular的scope
 */
angular.module("appendM",[]).controller("appendCtrl",function($scope){
  $scope.addElement = function(){
    var $div = $('<div ng-controller="myCtrl">{{content.label}}</div>');
    $(document.body).append($div);
    console.log(angular.element(document).injector());
    angular.element(document).injector().invoke(function($compile){
      var scope = angular.element($div).scope();
      $compile($div)(scope);
    });
  }
}).controller("myCtrl",function($scope){
  $scope.content = {label: "append html!"};
});
